home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / CEDITOR_ / CEDITORA.C1 < prev    next >
Text File  |  1990-06-11  |  4KB  |  154 lines

  1. /******************************************************************************
  2.  CEditorApp.c
  3.  
  4.                     The Editor Application Class
  5.  
  6.     This class implements a demo application for the CEditorDoc and CeditorPane
  7.     classes.
  8.     
  9.      Written by Johan A. Goossens
  10.      CompuServe: 74010,2576
  11.          
  12.     SUPERCLASS = CApplication.c
  13.  ******************************************************************************/
  14.  
  15. #include            <Commands.h>
  16. #include            <Global.h>
  17. #include            <CBartender.h>
  18. #include            "CEditorApp.h"
  19. #include            "CEditorDoc.h"
  20.  
  21. extern OSType        gSignature;
  22. extern CBartender    *gBartender;
  23.  
  24. #define                MENUtext        4
  25. #define                MENUstyle        12
  26. #define                MENUspace        13
  27. #define                MENUalign        14
  28.  
  29. #define                strTaskName        1
  30. #define                cmdSelectAll    1999
  31.  
  32. #define                textWindow        2000
  33. #define                aboutDialog        2000
  34.  
  35. /******************************************************************************
  36.  IEditorApp
  37.         Initialize a EditorApp object
  38.  ******************************************************************************/
  39.  
  40. void    CEditorApp::IEditorApp()
  41. {
  42.     IApplication(4, 20000L, 2000L);
  43. }
  44.     
  45.  
  46. /******************************************************************************
  47.  SetUpFileParameters {OVERRIDE}
  48.         Set parameters used by the Standard File Package
  49.  ******************************************************************************/
  50.  
  51. void    CEditorApp::SetUpFileParameters()
  52. {
  53.     inherited::SetUpFileParameters();
  54.     
  55.     gSignature = 'Gedt';
  56.  
  57.     sfNumTypes = 1;
  58.     sfFileTypes[0] = 'TEXT';
  59. }
  60.     
  61.  
  62. /******************************************************************************
  63.  SetUpMenus {OVERRIDE}
  64.     Setup the menus for the application. Currently the menus defined as
  65.     hierarchical in the resource file. The code for the menu handling methods
  66.     in this class and in other classes will work for regular and for
  67.     hierarchical menu structures.
  68.  ******************************************************************************/
  69.  
  70. void    CEditorApp::SetUpMenus()
  71. {
  72.     inherited::SetUpMenus();
  73.  
  74.     gBartender->SetDimOption(MENUtext, dimNONE);
  75.  
  76.     AddResMenu(GetMHandle(MENUfont), 'FONT');
  77.     gBartender->SetDimOption(MENUfont, dimNONE);
  78.     gBartender->SetUnchecking(MENUfont, TRUE);
  79.  
  80.     gBartender->SetDimOption(MENUsize, dimNONE);
  81.     gBartender->SetUnchecking(MENUsize, TRUE);
  82.  
  83.     gBartender->SetDimOption(MENUstyle, dimNONE);
  84.     gBartender->SetUnchecking(MENUstyle, TRUE);
  85.  
  86.     gBartender->SetDimOption(MENUalign, dimNONE);
  87.     gBartender->SetUnchecking(MENUalign, TRUE);
  88.  
  89.     gBartender->SetDimOption(MENUspace, dimNONE);
  90.     gBartender->SetUnchecking(MENUspace, TRUE);
  91. }
  92.     
  93.  
  94. /******************************************************************************
  95.  CreateDocument {OVERRIDE}
  96.         Make a document. This message is sent when the user chooses the
  97.         "New" command.
  98.  ******************************************************************************/
  99.  
  100. void    CEditorApp::CreateDocument()
  101. {
  102.     CEditorDoc        *theDocument;
  103.     
  104.     theDocument = new(CEditorDoc);
  105.     theDocument->IEditorDoc(this, textWindow, strTaskName, 800);
  106.     
  107.     theDocument->NewFile();
  108. }    
  109.  
  110.  
  111. /******************************************************************************
  112.  OpenDocument {OVERRIDE}
  113.  
  114.         Open an existing file and create a document object for displaying
  115.         information. This message is sent when the user chooses the
  116.         "Open..." command or when the application was launched by
  117.         double-clicking on a file or selecting file(s) and choosing
  118.         "Open" from the Finder.
  119.         
  120.         The macSFReply parameter is a record which contains information
  121.         about the file to open (name, volume number, etc.).
  122.  ******************************************************************************/
  123.  
  124. void    CEditorApp::OpenDocument(SFReply *macSFReply)
  125. {
  126.     CEditorDoc    *theDocument;
  127.  
  128.     theDocument = new(CEditorDoc);
  129.     theDocument->IEditorDoc(this, textWindow, strTaskName, 800);
  130.     theDocument->OpenFile(macSFReply);
  131. }
  132.  
  133.  
  134. /******************************************************************************
  135.  DoCommand {OVERRIDE}
  136.          If the "About CEditor Demo" command is selected, display the
  137.          about dialog and wait for the user to get sick and tired of that
  138.          stupid picture.
  139.  ******************************************************************************/
  140.  
  141. void CEditorApp::DoCommand(long theCommand)
  142. {
  143.     DialogPtr theDialog;
  144.     int    itemHit;
  145.  
  146.     if (theCommand == cmdAbout)
  147.     {
  148.         theDialog = GetNewDialog(aboutDialog, NULL, (void *) -1);
  149.         ModalDialog(NULL, &itemHit);
  150.         DisposDialog(theDialog);
  151.     }
  152.     else
  153.         inherited::DoCommand(theCommand);
  154. }